package com.yunweiweishi.xuhuanpaltform.yuhuan_app.service.imp;



import com.yunweiweishi.xuhuanpaltform.yuhuan_app.dao.UserDao;
import com.yunweiweishi.xuhuanpaltform.yuhuan_app.pojo.User;
import com.yunweiweishi.xuhuanpaltform.yuhuan_app.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class UserServiceImpl implements UserService {


    @Autowired
    private UserDao userDao;


    @Override
    public List<User> FindAll() {
        return userDao.findAll();
    }


    @Override
    public User addUser(User user) {
        return userDao.save(user);
    }

    @Override
    public User updateById(User user) {

        return userDao.save(user);
    }

    @Override
    public void deleteById(Long id) {

        userDao.deleteById(id);
    }
//
//    @Override
//    public List<User> findByToken(String token) {
//        return  userDao.findAll();
//    }


//    /**
//     * 判断用户登录
//     * @param phoneNumber
//     * @param password
//     */
//    @Override
//    public void loginWithPassword(String phoneNumber, String password) {
//
//        if (!CommonUtil.isMobile(phoneNumber)) {
//            throw new BusinessException(BusinessExceptionEnum.PHONE_NUMBER_ERROR);
//        }
//        // 判断密码是否为空
//        if ("".equals(password)) {
//            throw new BusinessException(BusinessExceptionEnum.PASSWORD_CANNOT_BE_NULL);
//        }
//
//        User user = userDao.findByPhoneNumber(phoneNumber);
//
//
//        if (user == null) {
//            throw new BusinessException(BusinessExceptionEnum.USER_NOT_EXIST);
//        }
//        // 验证密码是否正确
//        if (!user.getPassword().equals(MD5Util.md5(password, user.getPassword()))) {
//            throw new BusinessException(BusinessExceptionEnum.AUTH_REQUEST_ERROR);
//        }
//}







}
